//
//  PreferShopCell.m
//  Socrates
//
//  Created by shy on 15/4/6.
//  Copyright (c) 2015年 shy. All rights reserved.
//

#import "PreferShopCell.h"
#import "CircleImage.h"

@interface PreferShopCell () {
    UIView *upView_;
    UIView *downView_;
}

@end

@implementation PreferShopCell

- (void)awakeFromNib {
    [self configUpView];
    [self addSubview:upView_];
    [self configDownView];
    [self addSubview:downView_];
}

- (void)configUpView {
    CGFloat width = [UIScreen mainScreen].bounds.size.width;
    CGSize activityImageSize = CGSizeMake(140., 140.);
    CGFloat upviewHorizantalEdge = 5;
    CGSize upViewSize = CGSizeMake(width - upviewHorizantalEdge *2, 140.);
    CGFloat labelLeftEdge = 8.;
    CGFloat activityNameTopEdge = 10.;
    CGFloat labelSeparateEdge = 9.;
    CGFloat labelRightEdge = 20.;
    CGFloat activityNameHeight = 17.;
    CGFloat labelHeight = 15.;
    CGSize rightViewSize = CGSizeMake(width - activityImageSize.width - labelLeftEdge - labelRightEdge -labelLeftEdge, activityImageSize.height);
    upView_ = [[UIView alloc] initWithFrame:CGRectMake(upviewHorizantalEdge, upviewHorizantalEdge, upViewSize.width, upViewSize.height)];
    self.activityImage = [[UIImageView alloc] initWithFrame:CGRectMake(upviewHorizantalEdge, 0, activityImageSize.width, activityImageSize.height)];
    self.activityImage.image = [UIImage imageNamed:@"prefer_test_shop"];
    [upView_ addSubview:self.activityImage];
    
    UIView *rightView = [[UIView alloc] initWithFrame:CGRectMake(activityImageSize.width + labelLeftEdge +labelLeftEdge, 0, rightViewSize.width, rightViewSize.height)];
    [upView_ addSubview:rightView];
    
    self.activityName = [[UILabel alloc] initWithFrame:CGRectMake(0, activityNameTopEdge, rightViewSize.width, activityNameHeight)];
    self.activityName.font = [UIFont systemFontOfSize:14.];
    self.activityName.textColor = [UIColor blackColor];
    //    self.activityName.backgroundColor = [UIColor purpleColor];
    [rightView addSubview:self.activityName];
    
    UIImageView *timeImage = [[UIImageView alloc] initWithFrame:CGRectMake(0, activityNameTopEdge + activityNameHeight + labelSeparateEdge, 15, 14)];
    timeImage.image = [UIImage imageNamed:@"home_time"];
    [rightView addSubview:timeImage];
    
    self.time = [[UILabel alloc] initWithFrame:CGRectMake(20, activityNameTopEdge + activityNameHeight + labelSeparateEdge, rightViewSize.width - 20, labelHeight)];
    //    self.time.backgroundColor = [UIColor purpleColor];
    self.time.font = [UIFont systemFontOfSize:12.];
    self.time.textColor = [UIColor grayColor];
    [rightView addSubview:self.time];
    
    UIImageView *locationImage = [[UIImageView alloc] initWithFrame:CGRectMake(0, activityNameTopEdge + activityNameHeight + labelHeight + labelSeparateEdge*2, 15, 17.)];
    locationImage.image = [UIImage imageNamed:@"home_location"];
    [rightView addSubview:locationImage];
    
    self.location = [[UILabel alloc] initWithFrame:CGRectMake(20, activityNameTopEdge + activityNameHeight + labelHeight + labelSeparateEdge*2, rightViewSize.width - 20, labelHeight)];
    //    self.time.backgroundColor = [UIColor purpleColor];
    self.location.font = [UIFont systemFontOfSize:12.];
    self.location.textColor = [UIColor grayColor];
    [rightView addSubview:self.location];
    
    UIImageView *fee = [[UIImageView alloc] initWithFrame:CGRectMake(0, activityNameTopEdge + activityNameHeight + labelSeparateEdge*3 + labelHeight*2, 12., 17.)];
    fee.image = [UIImage imageNamed:@"home_fee"];
    [rightView addSubview:fee];
    
    self.activityFee = [[UILabel alloc] initWithFrame:CGRectMake(20, activityNameTopEdge + activityNameHeight + labelSeparateEdge*3 + labelHeight*2, width/5, labelHeight)];
    //    self.activityFee.backgroundColor = [UIColor purpleColor];
    self.activityFee.font = [UIFont systemFontOfSize:12.];
    self.activityFee.textColor = [UIColor grayColor];
    [rightView addSubview:self.activityFee];
    
    //    self.activityState = [[UIImageView alloc] initWithFrame:CGRectMake(0, activityNameTopEdge + activityNameHeight + labelHeight*3 + labelSeparateEdge*4, 55., 12)];
    //    self.activityState.image = [UIImage imageNamed:@"activity_state"];
    //    [rightView addSubview:self.activityState];
    
    UIImageView *male = [[UIImageView alloc] initWithFrame:CGRectMake(0, activityNameTopEdge + activityNameHeight + labelHeight*3 + labelSeparateEdge*4, 12, 12)];
    male.image = [UIImage imageNamed:@"male"];
    [rightView addSubview:male];
    
    self.numMale = [[UILabel alloc] initWithFrame:CGRectMake(20, activityNameTopEdge + activityNameHeight + labelHeight*3 + labelSeparateEdge*4, 35, labelHeight)];
    //    self.numMale.backgroundColor = [UIColor purpleColor];
    self.numMale.font = [UIFont systemFontOfSize:12.];
    self.numMale.textColor = [UIColor grayColor];
    [rightView addSubview:self.numMale];
    
    UIImageView *female = [[UIImageView alloc] initWithFrame:CGRectMake(65, activityNameTopEdge + activityNameHeight + labelHeight*3 + labelSeparateEdge*4, 9, 12)];
    female.image = [UIImage imageNamed:@"female"];
    [rightView addSubview:female];
    
    self.numFemale = [[UILabel alloc] initWithFrame:CGRectMake(85, activityNameTopEdge + activityNameHeight + labelHeight*3 + labelSeparateEdge*4, 35, labelHeight)];
    //    self.numFemale.backgroundColor = [UIColor purpleColor];
    self.numFemale.font = [UIFont systemFontOfSize:12.];
    self.numFemale.textColor = [UIColor grayColor];
    [rightView addSubview:self.numFemale];
    
    self.declareTime = [[UILabel alloc] initWithFrame:CGRectMake(rightViewSize.width - 25, activityNameTopEdge + activityNameHeight + labelSeparateEdge*3 + labelHeight*4 + 6, 40, labelHeight)];
    //    self.declareTime.backgroundColor = [UIColor purpleColor];
    self.declareTime.font = [UIFont systemFontOfSize:9.];
    self.declareTime.textColor = [UIColor grayColor];
    [rightView addSubview:self.declareTime];
    
}

- (void)configDownView {
    CGFloat width = [UIScreen mainScreen].bounds.size.width;
    CGFloat upviewHorizantalEdge = 5;
    CGSize upViewSize = CGSizeMake(width - upviewHorizantalEdge *2, 140.);
    CGSize downViewSize = CGSizeMake(width - upviewHorizantalEdge *2, 40.);
    downView_ = [[UIView alloc] initWithFrame:CGRectMake(upviewHorizantalEdge*2, upViewSize.height, downViewSize.width, downViewSize.height)];
    downView_.backgroundColor = [UIColor colorWithRed:239/255. green:239/255. blue:244/255. alpha:1.];
    
    self.userImage = [[UIButton alloc] initWithFrame:CGRectMake(upviewHorizantalEdge, 3, downViewSize.height - 3, downViewSize.height - 3)];
    UIImage *userImage = [CircleImage circleImageWithName:@"angela_test" borderWidth:0 borderColor:[UIColor clearColor]];
    [self.userImage setImage:userImage forState:UIControlStateNormal];
    [downView_ addSubview:self.userImage];
    
    self.shopName = [[UILabel alloc] initWithFrame:CGRectMake(upviewHorizantalEdge + downViewSize.height + 2, 11., width*0.4, 18.)];
    //    self.userName.backgroundColor = [UIColor purpleColor];
    self.shopName.font = [UIFont systemFontOfSize:13.];
    self.shopName.textColor = [UIColor blackColor];
    [downView_ addSubview:self.shopName];
    
    self.locates = [[UILabel alloc] initWithFrame:CGRectMake(upviewHorizantalEdge + downViewSize.height + 2 + 0.4*width, 11., width*0.2, 18.)];
    //    self.userSchool.backgroundColor = [UIColor purpleColor];
    self.locates.font = [UIFont systemFontOfSize:12.];
    self.locates.textColor = [UIColor grayColor];
    [downView_ addSubview:self.locates];
    
    UIImageView *likeImage = [[UIImageView alloc] initWithFrame:CGRectMake(downViewSize.width - 35, 5, 20., 17.)];
    likeImage.image = [UIImage imageNamed:@"home_like"];
    [downView_ addSubview:likeImage];
    
    self.likes = [[UILabel alloc] initWithFrame:CGRectMake(downViewSize.width - 35, 23., 22, 15.)];
    //    self.likes.backgroundColor = [UIColor purpleColor];
    self.likes.font = [UIFont systemFontOfSize:12.];
    self.likes.textColor = [UIColor grayColor];
    self.likes.textAlignment = NSTextAlignmentCenter;
    [downView_ addSubview:self.likes];
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];
}

@end
